-
Notifications
You must be signed in to change notification settings - Fork 13k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix documentation not showing on localStorage error #81964
Conversation
Fixes rust-lang#81928 “Ask forgiveness not permission” : this makes the code both simpler and more robust
Some changes occurred in HTML/CSS/JS. |
Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @GuillaumeGomez (or someone else) soon. If any changes to this PR are deemed necessary, please add them as extra commits. This ensures that the reviewer can see what has changed since they last reviewed the code. Due to the way GitHub handles out-of-date commits, this should also make it reasonably obvious what issues have or haven't been addressed. Large or tricky changes may require several passes of review and changes. Please see the contribution instructions for more information. |
I really like this simplification which allows us to handle all cases. Thanks! @bors: r+ rollup |
📌 Commit 16f0ccd has been approved by |
try { | ||
window.localStorage.setItem(name, value); | ||
} catch(e) { | ||
// localStorage is not accessible, do nothing |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wouldn't it make sense to attempt to call localStorage.clear()
here in case enough data accumulated to reach the per-site limit?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why would you want to remove all your data if you can't add more?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's assuming something filled up the storage to its limit which prevents storing new data, e.g. due to previous iterations of the site.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We store very little amount of information in the local storage (less than 40 bytes iirc), so we should be fine. ;)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe this can be discussed outside of the context of this pull request ?
If new behavior needs to be introduced, it can be independently of this bug fix.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No need, if there's nothing that could cause unbounded growth then the limitation is probably due to something else, e.g. a browser simply having localstorage disabled, clear()
wouldn't help with that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are we good to merge, then ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I already approved it so it should be merged in the next days.
Fix documentation not showing on localStorage error Fixes rust-lang#81928 The [documentation for setItem](https://developer.mozilla.org/en-US/docs/Web/API/Storage/setItem) specifies: > developers should make sure to always catch possible exceptions from setItem()
Fix documentation not showing on localStorage error Fixes rust-lang#81928 The [documentation for setItem](https://developer.mozilla.org/en-US/docs/Web/API/Storage/setItem) specifies: > developers should make sure to always catch possible exceptions from setItem()
Fix documentation not showing on localStorage error Fixes rust-lang#81928 The [documentation for setItem](https://developer.mozilla.org/en-US/docs/Web/API/Storage/setItem) specifies: > developers should make sure to always catch possible exceptions from setItem()
Fix documentation not showing on localStorage error Fixes rust-lang#81928 The [documentation for setItem](https://developer.mozilla.org/en-US/docs/Web/API/Storage/setItem) specifies: > developers should make sure to always catch possible exceptions from setItem()
Rollup of 16 pull requests Successful merges: - rust-lang#79983 (fix indefinite article in cell.rs) - rust-lang#81831 (Don't display `mut` in arguments for functions documentation) - rust-lang#81947 (Relax ItemCtxt::to_ty lifetime) - rust-lang#81954 (RELEASES.md 1.50: Group platform support notes together) - rust-lang#81955 (bootstrap: Locate llvm-dwp based on llvm-config bindir) - rust-lang#81959 (Fix assosiated typo) - rust-lang#81964 (Fix documentation not showing on localStorage error) - rust-lang#81968 (bootstrap: fix wrong docs installation path) - rust-lang#81990 (Make suggestion of changing mutability of arguments broader) - rust-lang#81994 (Improve long explanation for E0542 and E0546) - rust-lang#81997 (dist: include src/build_helper as part of the crate graph for rustc-dev) - rust-lang#82003 (Stack probes: fix error message) - rust-lang#82004 (clean up clean::Static struct) - rust-lang#82011 (Fix private intra-doc warnings on associated items) - rust-lang#82013 (Tell user how to fix CI file being not up to date) - rust-lang#82017 (Fix typo in mod.rs) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
Fixes #81928
The documentation for setItem specifies: